#coding=utf-8
'''
Created on Dec 4, 2015
@author: DQA wangpeng
'''

import unittest
import HTMLTestRunner
import os
import time
from appium import webdriver

list_testcase=r'//Users/dqatcl/apptest/Testcase'

def creatsuite():
    #build a suite
    testunit = unittest.TestSuite()
    
    #discover
    discover = unittest.defaultTestLoader.discover(list_testcase,
                                                   pattern = 'function_*.py',
                                                   top_level_dir = None)
    #loop the TestSuite
    
    for test_suite in discover:
        for test_case in test_suite:
            testunit.addTest(test_case)
            print testunit
            
    return testunit

alltestnames = creatsuite()

filename = '//Users//dqatcl///apptest//report//testreport.html'

fp = open(filename,'wb')

runner = HTMLTestRunner.HTMLTestRunner(
    stream=fp,
    title=u'华为M130 ios自动化测试报告',
    description = u'请查收具体的测试报告，如有红色背景代表测试失败，请各位查看具体问题,需要点击detail查看明细'
    )
                                                
#excute the Testcase
runner.run(alltestnames)